<template>
  <div id="deliverList">
    <el-input size="small" @keyup.enter.native="searchHandle" style="width: 300px" v-model="keywords"
              placeholder="搜索投递者、投递职位"></el-input>
    <el-button @click="searchHandle()" style="margin-left: 10px" type="primary" icon="el-icon-search" size="small">搜索
    </el-button>
    <el-table
        height="536"
        :data="deliverList"
        v-loading="loading"
        element-loading-text="拼命加载中"
        style="width: 99.5%">
      <el-table-column
          label="序号"
          align="center"
          type="index"
          :index="indexMethod">
      </el-table-column>
      <el-table-column
          label="简历名称"
          prop="resumeName"
          align="center"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          label="投递者"
          prop="userName"
          align="center"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          label="投递职位"
          align="center"
          prop="jobName"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          label="简历状态"
          prop="createTime"
          align="center"
          show-overflow-tooltip>
        <template slot-scope="scope">
          {{scope.row.state==0?'简历评审':
            scope.row.state==1?'笔试':
                scope.row.state==2?'面试':
                scope.row.state==3?'通过':'未通过'
          }}
        </template>
      </el-table-column>
      <el-table-column
          label="投递时间"
          prop="createTime"
          sortable
          align="center"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          label="操作"
          align="center"
          width="220%">
        <template slot-scope="scope">
          <el-tooltip class="item" effect="light" content="简历详情" placement="top" >
            <el-button @click="getResumeInfo(scope.row.resumeId)" class="iconfont icon-xiangqing" size="mini" type="success"></el-button>
          </el-tooltip>
          <el-tooltip class="item" effect="light" content="评审通过" placement="top" >
            <el-button @click="passHandler(scope.row.deliverId,scope.row.resumeName,1)" size="mini" class="iconfont icon-shenhetongguo"
                       type="success"></el-button>
          </el-tooltip>
          <el-tooltip class="item" effect="light" content="评审不通过" placement="top" >
            <el-button @click="passHandler(scope.row.deliverId,scope.row.resumeName,4)" size="mini" class="iconfont icon-shenhebutongguo"
                       type="danger"></el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        background
        layout="total,prev, pager, next"
        :total="total"
        align="center"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="pageSize"
        :hide-on-single-page="value"
        style="padding-top: 15px"
    >
    </el-pagination>
    <el-dialog title="简历详情" :visible.sync="dialogTableVisible" top="0" >
      <el-descriptions :column="3"  border>
        <template slot="extra">
          <el-tag type="info">{{ this.resume.resumeName }}</el-tag>
        </template>
      <el-descriptions-item label="照片">
        <el-image :src="this.resume.photoUrl" style="width:40px;height:50px">
          <div slot="error" class="image-slot">
            <i class="el-icon-picture-outline" style="font-size: 40px;color:#E4E7ED"></i>
          </div>
        </el-image>
      </el-descriptions-item>
      <el-descriptions-item label="姓名">{{ this.resume.name }}</el-descriptions-item>
      <el-descriptions-item label="性别">{{ this.resume.sex }}</el-descriptions-item>
      <el-descriptions-item label="年龄">{{ this.resume.age }}</el-descriptions-item>
      <el-descriptions-item label="民族">{{ this.resume.nation }}</el-descriptions-item>
      <el-descriptions-item label="籍贯">{{ this.resume.nativePlace }}</el-descriptions-item>
      <el-descriptions-item label="居住地">{{this.resume.residence}}</el-descriptions-item>
      <el-descriptions-item label="手机号">{{this.resume.tel}}</el-descriptions-item>
      <el-descriptions-item label="邮箱">{{this.resume.email}}</el-descriptions-item>
      <el-descriptions-item label="政治面貌">{{this.resume.politicsStatus}}</el-descriptions-item>
      <el-descriptions-item label="期望薪资">{{this.resume.expectSalary}}</el-descriptions-item>
        <el-descriptions-item label="最高学历">{{ this.resume.maxEdu }}</el-descriptions-item>
      <el-descriptions-item label="毕业院校">{{this.resume.university}}</el-descriptions-item>
      <el-descriptions-item label="毕业时间">{{this.resume.graduationTime}}</el-descriptions-item>
      <el-descriptions-item label="工作时间" :span="2">{{this.resume.workTime}}</el-descriptions-item>
        <el-descriptions-item label="自我评价" :span="3">{{this.resume.selfEvaluation}}</el-descriptions-item>
        <el-descriptions-item label="技能" :span="3">{{this.resume.skill}}</el-descriptions-item>
      <el-descriptions-item label="工作经历" :span="3">{{this.resume.workExperience}}</el-descriptions-item>
      <el-descriptions-item label="项目经历" :span="3">{{this.resume.project}}</el-descriptions-item>
      <el-descriptions-item label="所获荣誉" :span="3">{{this.resume.honor}}</el-descriptions-item>
      <el-descriptions-item  label="附件" :span="3">
       <el-link :href="this.resume.accessoryUrl" type="primary"> 下载</el-link>
      </el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>
</template>

<script>
import {getDeliverList, passResume, resumeInfo} from "../../network/companyUser";
export default {
  name: "ResumeManage",
  components:{

  },
  data() {
    return {
      loading: true,
      keywords: '',
      value: false,
      currentPage: 1,
      total: 1,
      pageSize: 9,
      dialogTableVisible:false,
      companyName:'',
      formLabelWidth:"120px",
      deliverList:[],
      resume:{}
    }
  },

  created() {
    this.companyName= localStorage.getItem("company_companyName");
    this.handleCurrentChange(this.currentPage);
  },
  methods: {
    handleCurrentChange(currentPage) {
      getDeliverList(this.keywords, currentPage, this.pageSize,this.companyName,0).then(res => {
        this.loading = false;
        this.total = res.data.data.total;
        this.deliverList = res.data.data.list;
        this.currentPage = currentPage;
      })
    },
    searchHandle() {
      this.currentPage = 1;
      this.handleCurrentChange(this.currentPage)
    },
    indexMethod(index) {
      return (this.currentPage - 1) * this.pageSize + 1 + index;
    },

    passHandler(deliverId,resumeName,state) {
      passResume(deliverId,state).then(res => {
        if (res.data.code == 100) {
          this.$message.success('简历' + resumeName +"评审完成");
        }
        this.handleCurrentChange(this.currentPage)
      }).catch()
    },
    getResumeInfo(resumeId) {
      resumeInfo(resumeId).then(res=>{
        if(res!=undefined){
          this.resume=res.data.data;
          this.dialogTableVisible=true;
        }
      })
    }
  },

}

</script>

<style scoped>
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  min-width: 130px;
  height: 50px;
  color: #99a9bf;
}

.demo-table-expand .el-form-item {
  margin-left: 50px;
  margin-bottom: 0;
  width: 40%;
}

.el-form-item__content {
  height: 50px;
}
</style>